<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="./css/try.css"/>
	</head>
	<script type="text/javascript">
			//图片转换
            window.onload = init;
            var imgs;
            var imgs_array;
            var index = 0;
            function init() {
            	imgs_array = new Array("./img/njcit_logo.JPG", "./img/njcit_logo.JPG", "./img/njcit_logo.JPG");
            	imgs = document.getElementById("imgs");
            	setRoll();
            	myclock();
            	yanzheng1();
            	yanzheng2 = document.getElementById("yanzhengID");
            	yanzheng2.onclick = Reset1;
            }

            function setRoll() {
            	if (index == imgs_array.length) {
            		index = 0;
            	}
            	imgs.src = imgs_array[index];
            	index++;
            	setTimeout("setRoll()", 1000)
            }
            //时间
            function myclock() {
            	var time = new Date();
            	var year = time.getFullYear();
            	var month = time.getMonth() + 1;
            	var day = time.getDate();
            	var hour = time.getHours();
            	var min = time.getMinutes();
            	var sec = time.getSeconds();
            	hour = (hour < 10) ? "0" + hour : hour;
            	min = (min < 10) ? "0" + min : min;
            	sec = (sec < 10) ? "0" + sec : sec;
            	var str = year + "年" + month + "月" + day + "日" + hour + "时" + min + "分" + sec + "秒";
            	document.getElementById("display").innerHTML = str;
            	setTimeout("myclock()", 1000);
            }

            function yanzheng1() {
            	//验证码
            	var tt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
            	var tt2 = "0123456897";
            	var s = "";
            	for (var e = 0; e < 2; e++) {
            		var index = Math.floor(Math.random() * 52);
            		var index2 = Math.floor(Math.random() * 10);
            		s += tt2.charAt(index2) + tt.charAt(index);
            	}
            	document.getElementById("yanzhengID").innerHTML = s;
            }

            function Reset1() {
            	document.getElementById("yanzhengID").innerHTML = null;
            	yanzheng1();
            }
            //昵称，密码
            function login() {
            	//用户名
				var yonghu;
            	var str = document.getElementById("username").value;
            	if (str.length == 0){
					username_msg.innerHTML = "用户名不能为空";
					username_msg.style.color = "red";
					yonghu = false;
				}
				else{
					username_msg.innerHTML = "ok";
					username_msg.style.color = "green";
					yonghu = true;
				}
//             	for (var i = 0; i < str.length; i++) {
//             		var w = str.charAt(i);
//             		if (!((w >= '0' && w <= '9') || (w >= 'a' && w <= 'z') || (w >= 'A' && w <= 'Z'))){
// 					    yonghu = false;
//             			alert("用户名不合法");
// 						}else{yonghu=true;}
//             	}
            	//密码
				var mima;
            	var cc = document.getElementById("pwd").value;
            	if (cc.length == 0){
            		pwd_msg.innerHTML = "密码不能为空";
					pwd_msg.style.color = "red";
					mima=false;
					}
				else{
					pwd_msg.innerHTML = "ok";
					pwd_msg.style.color = "green";
					mima=true;
					}
            	//验证验证码
				var yanzhengflag;
				var yanzhengText = document.getElementById("yanzheng");
				var yanzhengID = document.getElementById("yanzhengID");
            	if (yanzhengText.value.toUpperCase() != yanzhengID.innerHTML.toUpperCase()) {
            		yanzheng_msg.innerHTML = "验证码错误";
					yanzheng_msg.style.color = "red";
            		yanzhengflag = false;
            	} else {
            		yanzheng_msg.innerHTML = "OK";
            		yanzhengflag = true;
            	}
				if(yonghu&&mima&&yanzhengflag){
				window.location.replace("result.html");
				}
				
            }
			


	</script>
	<body>
		<div id="whole">
			<div id="pic">
				<img id="imgs" src="./img/njcit_logo.JPG" />				
			</div>
			<div id="zhuce">
				<div id="display"><script>myclock()</script></div>
				<form>
				<table>
					<tr>
						<td>昵称</td>
						<td>
							<input id="username" type="text" placeholder="昵称" onblur="username_blur()" />										
						</td>
						<td><span id="username_msg"></span>	</td>
					</tr>
					<tr>
						<td>密码</td>
						<td><input id="pwd" type="password" placeholder="密码" onblur="pwd_blur()"/></td>
						<td><span id="pwd_msg"></span></td>
					</tr>
					<tr>
						<td>验证码</td>
						<td><input id="yanzheng" type="text" onblur="yanzheng_blur()" /></td>
						<td><a href="#"><span id="yanzhengID"></span></a></td>
						<td><span id="yanzheng_msg" ></span></td>
					</tr>
					<tr>
						<td class="third" colspan="2"><input id="register" type="button" value="登录" onclick="login()" />
						<input id="reset" type="reset"/></td>					
					</tr>
				</table>
				</form>
			</div>
		</div>
	</body>
</html>
